# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=woff2
pkgver=1.0.2
pkgrel=1
pkgdesc="Web Open Font Format 2 reference implementation"
options="!check" # No testsuite
url="https://github.com/google/woff2"
arch="all"
license="GPL-3.0-or-later"
makedepends="brotli-dev cmake"
subpackages="$pkgname-dev lib${pkgname}common:_common lib${pkgname}enc:_enc
	lib${pkgname}dec:_dec"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/woff2/archive/v$pkgver.tar.gz
	dont-set-rpath.patch
	install-executables.patch
	"

build() {
	cmake . \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_SKIP_BUILD_RPATH=ON
	make
}

package() {
	make DESTDIR="$pkgdir" PREFIX=/usr install
}

_common() {
	pkgdesc="$pkgdesc (common library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libwoff2common.so.* "$subpkgdir"/usr/lib
}

_dec() {
	pkgdesc="$pkgdesc (encoder library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libwoff2enc.so.* "$subpkgdir"/usr/lib
}

_enc() {
	pkgdesc="$pkgdesc (decoder library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libwoff2dec.so.* "$subpkgdir"/usr/lib
}

sha512sums="c788bba1530aec463e755e901f9342f4b599e3a07f54645fef1dc388ab5d5c30625535e5dd38e9e792e04a640574baa50eeefb6b7338ab403755f4a4e0c3044d  woff2-1.0.2.tar.gz
e60add16905b597ed3b10cfe3f4c90d43db28c86466bb65e880a91e84f388e9f03e3a16d0012e717ca170456d91b748c8de5ade4882e8f31e2a60620c183df5f  dont-set-rpath.patch
49bd21014c427a13fd19dd80f821a48ed290bb4978b77ccf72ba424e90deb11db604b452cbd315f0d372c176d3093a685c892a8088f9d54a28bdb5a3bb6f0adb  install-executables.patch"
